package com.fowo.api.documentCirculation.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.Objects;

/**
 * 单据流转运行时模型
 * @author yl_ls
 */
@Getter
@Setter
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DataTaskRuntimeModel {
    private Long id;
    private String code;
    private String name;
    private String type;
    private String uiType;
    private String invokeAfterPushService;
    private String invokeAfterPushMethod;
    private String invokeAfterPullService;
    private String invokeAfterPullMethod;
    private java.util.Date createTime;
    private Long createUser;
    private java.util.Date lastUpdateTime;
    private Long lastUpdateUser;
    private Boolean delFlag;
    private DataTaskBranchVo mainBranch;
    private DataTaskBranchVo subBranch;

    /**
     * 当前任务是否为从主子表到单表
     */
    public boolean isMainSubToOne() {
        return mainBranch != null && subBranch != null &&
                Objects.equals(mainBranch.getToTable(), subBranch.getToTable()) &&
                Objects.equals(mainBranch.getToAssociation(), subBranch.getToAssociation());
    }
}
